Каждая хорошо спроектированная консольная утилита должна принимать аргументы в виде опций (например, -h или --help), опций с параметрами (--log-level 2) или позиционных параметров (cp file1 file2).
Опции отличаются от позиционных параметров тем, что начинаются с одного или двух дефисов. Проблемы возникают, когда позиционные аргументы тоже начинаются с дефиса — например, если нужно удалить файл с именем -rf: команда rm -rf в таком случае не работает как ожидается.
Общепринятый способ решения этой проблемы — поддержка разделителя --. Аргументы, идущие после --, никогда не интерпретируются как опции:
$ echo test > -rf $ cat -rf cat: invalid option -- 'r' Try 'cat --help' for more information. $ cat -- -rf test $ rm -- -rf $ cat -- -rf cat: -rf: No such file or directory
Модуль argparse автоматически обрабатывает -- за тебя.
Каждая хорошо спроектированная консольная утилита должна принимать аргументы в виде опций (например, -h или --help), опций с параметрами (--log-level 2) или позиционных параметров (cp file1 file2).
Опции отличаются от позиционных параметров тем, что начинаются с одного или двух дефисов. Проблемы возникают, когда позиционные аргументы тоже начинаются с дефиса — например, если нужно удалить файл с именем -rf: команда rm -rf в таком случае не работает как ожидается.
Общепринятый способ решения этой проблемы — поддержка разделителя --. Аргументы, идущие после --, никогда не интерпретируются как опции:
$ echo test > -rf $ cat -rf cat: invalid option -- 'r' Try 'cat --help' for more information. $ cat -- -rf test $ rm -- -rf $ cat -- -rf cat: -rf: No such file or directory
Модуль argparse автоматически обрабатывает -- за тебя.
Telegram and Signal Havens for Right-Wing Extremists
Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.
Tata Power whose core business is to generate, transmit and distribute electricity has made no money to investors in the last one decade. That is a big blunder considering it is one of the largest power generation companies in the country. One of the reasons is the company's huge debt levels which stood at ₹43,559 crore at the end of March 2021 compared to the company’s market capitalisation of ₹44,447 crore.
Библиотека Python разработчика | Книги по питону from jp